/****private function***/

function __init(){
	$addEvent($('userList') , "click" , setActionWindow);
}

function delFn(){
	var text = http_request.responseText;
	if(text=="deny"){
		location.href="index.php";
		return;
	}
	if(text=="fail"){
		alert("Delete Fail");
	}
	/*var trs = $('userList').getElementsByTagName('tr');
	for(var i=1 , l=trs.length-2;i<l;i++){
		if(trs[i].getAttribute("tag")==text)	
			$('userList').getElementsByTagName('tbody')[0].removeChild(trs[i]);
	}*/
	alert("Delete Succeed!");
}

function setActionWindow(e){
	var el = getSrcEl(e);
	if(el.tagName=="INPUT"){
		var action=el.getAttribute("tag");
		var userid = el.getAttribute("userid");
		if(action=="add"){
			showAddWindow();
		}
		if(action=="modify"){
			makeModifyUser(el);
		}
		if(action=="saveModify"){
			ajaxModifyUser(el , userid);
		}
		if(action=="delete"){
			ajaxDeleteUser(userid);
		}
	}
}

function ajaxDeleteUser(uid){
	if(confirm("Do you really want to delete the invitation?The action can't be recovered!")){
		var action = "action=delcardinfo";
		var userid = "&cardinfoid="+encodeURI(uid);
		var param = action+userid;
		makeAjaxRequest(ajaxUrl , param , true , delFn);
	}
}

__domready();